<!--
To change this template, choose Tools | Templates
and open the template in the editor.
-->
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
    <head>

        <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
        <link rel="stylesheet" type="text/css" href="maintenancePagesCSS.css" />
        <title>Customer Contact</title>
        <style type='text/css'>
            <!--
            body {
                background-color: #454343;
                margin-left: 17px;
                margin-top: 0px;
                margin-right: 0px;
                margin-bottom: 0px;
            }
            -->
        </style>
    </head>
    <body>
        <?php
            $hasPermission = $_GET['Func'] == "Edit";
            $custContactLogID = $_GET['custContID'];
            include "Datasource.php";
            include "CustContactLog.php";
            include "CustContactLogDao.php";
            $conn = new Datasource("localhost","theanykey","root","");
            $ccDao = new CustContactLogDao();
            $custContact = $ccDao->getObject($conn, $custContactLogID);
        ?>
        <center>
            <h2><?php if($hasPermission) echo "Edit "; else echo "View ";?>Customer Contact Log Entry            </h2>
            <form id="frmEditCustContact" action="CustContactPopupEditFunct.php" method="post">
            <table>
                <tr>
                    <td>
                       Notes
                    </td>
                    <td>
                        <textarea
                            <?php
                            if(!$hasPermission) echo " readonly='true' ";
                            ?>
                            rows="4" cols="40" id="txtCCNotes" name="txtCCNotes"><?php echo $custContact->getContactNotes();?></textarea>
                    </td>
                </tr>
            </table>
            <input type="hidden" value="<?php echo $_SESSION['userID'];?>" name="empID" />
            <br/>
            <br/>
                <input type="hidden" name="ccPK" value="<?php echo $custContact->getCntctLogID(); ?>" />
                <?php
                if($hasPermission)
                {
                    ?>
                <input type="button" value="Submit" onClick="checkForm();" />
                <?php
                }
                ?>
                &nbsp;
                <input type="Button" value="Cancel" onClick="window.close();" />
            </form>
        </center>
        </body>
        <script type="text/javascript">
            function checkForm()
            {
                strErrors = "Please correct the following to submit the form:";
                strCheck = strErrors;

                strErrors += document.getElementById("txtCCNotes").value == "" ? "\n  - Notes must have a value" : "";

                if(strErrors == strCheck)
                {
                    document.getElementById("frmEditCustContact").submit();
                }
                else
                {
                    alert(strErrors);
                }
            }
        </script>
</html>
